package com.example.ftp.Controller.MainWindow.FileList;

import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
import org.apache.commons.net.ftp.FTPFile;

public class FileItem {
    private final SimpleStringProperty name;
    private final SimpleStringProperty date;
    private final SimpleStringProperty type;
    private final SimpleLongProperty size;

    private boolean isDir = false;

    public FileItem(String name, String date, String type, long size, boolean isDir) {
        this.name = new SimpleStringProperty();
        this.date = new SimpleStringProperty();
        this.type = new SimpleStringProperty();
        this.size = new SimpleLongProperty();

        this.isDir = isDir;

        setName(name);
        setDate(date);
        setType(type);
        setSize(size);
    }

    public FileItem(FTPFile file) {
        this(file.getName(), file.getTimestamp().getTime().toString(), String.valueOf(file.getType()), file.getSize(),
                file.isDirectory());
        type.set(getType().equals("1")?"Folder":"File");
    }


    public String getName() {
        return name.get();
    }

    public SimpleStringProperty nameProperty() {
        return name;
    }

    public void setName(String name) {
        this.name.set(name);
    }

    public String getDate() {
        return date.get();
    }

    public SimpleStringProperty dateProperty() {
        return date;
    }

    public void setDate(String date) {
        this.date.set(date);
    }

    public String getType() {
        return type.get();
    }

    public SimpleStringProperty typeProperty() {
        return type;
    }

    public void setType(String type) {
        this.type.set(type);
    }

    public long getSize() {
        return size.get();
    }

    public SimpleLongProperty sizeProperty() {
        return size;
    }

    public void setSize(long size) {
        this.size.set(size);
    }

    public boolean isDir() {
        return isDir;
    }

    public void setDir(boolean dir) {
        isDir = dir;
    }
}
